export function createFSAReducer(initialState, handlers) {
  return function reducer(state = initialState, action) {
    if (Object.hasOwnProperty.call(handlers, action.type)) {
      return handlers[action.type](state, action);
    }
    return state;
  };
}

/**
 export default function reducer(state = initState, action) {
  switch (action.type) {
    case INCREMENT:
      return {
        count: state.count + 1,
      };
    case DECREMENT:
      return {
        count: state.count - 1,
      };
    case RESET:
      return { count: 0 };
    case GET_USER_INFO_SUCCESS:
      return { ...state, userInfo: action.userInfo };
    default:
      return state;
    }
  }
 */
export default function (handlers) {
  const { CONSTRUCT: construct, ...rest } = handlers;
  const initialState = construct ? construct() : {};

  return function reducer(state = initialState, action) {
    if (Object.hasOwnProperty.call(rest, action.type)) {
      return rest[action.type](state, action);
    }
    return state;
  };
}
